package com.iotek.ssm.service.impl;

import com.iotek.ssm.mapper.PositionLevelMapper;
import com.iotek.ssm.mapper.SectionMapper;
import com.iotek.ssm.pojo.Position;
import com.iotek.ssm.pojo.PositionLevel;
import com.iotek.ssm.pojo.Section;
import com.iotek.ssm.service.SectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("sectionService")
public class SectionServiceImpl implements SectionService {

    @Autowired
    private SectionMapper sectionMapper;

    @Autowired
    private PositionLevelMapper positionLevelMapper;

    public List<Section> findSections() throws Exception {
        return sectionMapper.findSections();
    }

    public Section findSection(Integer id) throws Exception {
        return sectionMapper.findSection(id);
    }

    public List<Position> findPositions(Integer sectionId) throws Exception {
        return sectionMapper.findPositions(sectionId);
    }

    public void addSection(String section) throws Exception {
        sectionMapper.addSection(section);
    }

    public void addPosition(Position position) throws Exception {
        sectionMapper.addPosition(position);
    }

    public void delPosition(Integer positionId) throws Exception {
        sectionMapper.delPosition(positionId);
    }

    public void delSectionAndPositions(Integer sectionId) throws Exception {
        sectionMapper.delSectionAndPositions(sectionId);
    }

    public void updateSection(Section section) throws Exception {
        sectionMapper.updateSection(section);
    }

    public void updatePosition(Position position) throws Exception {
        sectionMapper.updatePosition(position);
    }

    public List<PositionLevel> getLevelList() throws Exception {
        return positionLevelMapper.getLevelList();
    }
}
